package com.gitee.wsl.compose.use


import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import kotlin.collections.Map

/**
 * Description:
 * @author Junerver
 * date: 2024/3/8-9:24
 * Email: junerver@gmail.com
 * Version: v1.0
 */
//typealias Component = @Composable () -> Unit
//
//private val LocalNavHostController: ProvidableCompositionLocal<NavHostController> =
//    staticCompositionLocalOf { error("provide first") }

//@Composable
//fun useNavigate() = LocalNavHostController.current


//@Composable
//fun useRoutes(routes: Map<String, Component>) {
//    val navController = rememberNavController()
//    return CompositionLocalProvider(LocalNavHostController provides navController) {
//        NavHost(navController = navController, startDestination = "/") {
//            routes.map { route ->
//                composable(route.key) { route.value() }
//            }
//        }
//    }
//}

//@Composable
//fun useRoutes(routes: Map<String, Component>,builder: NavGraphBuilder.() -> Unit) {
//    val navController = rememberNavController()
//    return CompositionLocalProvider(LocalNavHostController provides navController) {
//        NavHost(navController = navController, startDestination = "/") {
//            routes.map { route ->
//                composable(route.key) { route.value() }
//            }
//            builder()
//        }
//    }
//}

